package 笔试;

import java.util.Scanner;

public class 笔试4399 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = new String();
        int m = Integer.parseInt(sc.nextLine());
        s =sc.nextLine();
        int k=s.length();
        for (int i = 1; i < m; i++) {
            String s1 = sc.nextLine();
            k=Math.min(s1.length(),k);
            for (int j = 0; j < k; j++) {
                if(s.charAt(j)==s1.charAt(j)){

                }else{
                    s=s.substring(0,j);
                    break;
                }
            }
        }
        System.out.println(s);

    }
}
